package com.bw.demo_mvvm.net

import retrofit2.CallAdapter
import retrofit2.Retrofit
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type

/**
 * @Author : ZhouZiYao
 * @Time : On 2023/11/16 19:17
 * @Description :
 */
class LiveDataCallAdapterFactory: CallAdapter.Factory() {
    override fun get(
        returnType: Type,
        annotations: Array<out Annotation>,
        retrofit: Retrofit
    ): CallAdapter<*, *>? {
        val parameterUpperBound = getParameterUpperBound(0, returnType as ParameterizedType)
        return LiveDataCallAdapter<Any>(parameterUpperBound)
    }
}